package com.ysxsoft.wdg.widget.alertview;

import android.app.Activity;


public class AlertUtils {

    private static AlertView alertView;


    public static void payAlert(final Activity activity) {

        if (alertView != null)
            alertView = null;
        alertView = new AlertView(null, "正在前往支付....",
                null, null,
                null, activity, AlertView.Style.Alert, new OnItemClickListener() {
            @Override
            public void onItemClick(Object o, int position) {
                if (position == -1) {
                    if (null != alertView && alertView.isShowing())
                        alertView.dismiss();
                } else if (position == 0) {
                    if (null != alertView && alertView.isShowing())
                        alertView.dismiss();
                }
            }
        }).setCancelable(false);
        alertView.show();
    }


    public static void showMsg(final Activity activity, String str) {

        if (alertView != null)
            alertView = null;
        alertView = new AlertView(null, str,
                null, null,
                null, activity, AlertView.Style.Alert, new OnItemClickListener() {
            @Override
            public void onItemClick(Object o, int position) {
                if (position == -1) {
                    if (null != alertView && alertView.isShowing())
                        alertView.dismiss();
                } else if (position == 0) {
                    if (null != alertView && alertView.isShowing())
                        alertView.dismiss();
                }
            }
        }).setCancelable(true);
        alertView.show();
    }

    public static void dismissAlert() {
        if (alertView != null && alertView.isShowing()) {
            alertView.dismiss();
        }
    }
}
